<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body><script>
     var sum = [33,42,45,21,45,5];
    for(var i = 0 ; i < sum.length; i++){
        for(var j = 0; j <sum.length-1-i; j++){
            if(sum[j]<sum[j+1]){
                temp = sum[j];
                sum[j]= sum[j+1];
                sum[j+1] = temp;
            }
        }
    }
    console.log(sum);
    //直接进行排序 但是直接sum.sort这样排序会有问题
    sum.sort()
    sum.sort(function(a,b){
        return a - b;//升序的顺序排列 降序直接 b-a
    })
    
    </script>
</body>
</html>